package org.EasyDevelop.Utils;

public class StringUtils {
    public static String upperCaseFirstLetter(String field){
        if(org.apache.commons.lang3.StringUtils.isEmpty(field)){
            return field;
        }
        return field.substring(0,1).toUpperCase() + field.substring(1);
    }

    public static String lowerCaseFirstLetter(String field){
        if(org.apache.commons.lang3.StringUtils.isEmpty(field)){
            return field;
        }
        return field.substring(0,1).toLowerCase() + field.substring(1);
    }

    //字段名称转换
    public static String processFiled(String field,Boolean upperCaseFirstLetter){
        StringBuffer sb = new StringBuffer();
        String[] fields = field.split("_");
        sb.append(upperCaseFirstLetter?StringUtils.upperCaseFirstLetter(fields[0]):StringUtils.lowerCaseFirstLetter(fields[0]));
        for (int i = 1; i < fields.length; i++) {
            sb.append(StringUtils.upperCaseFirstLetter(fields[i]));
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        System.out.println(StringUtils.upperCaseFirstLetter("company"));
        System.out.println(StringUtils.lowerCaseFirstLetter("Company"));
    }
}
